ALMaSS  1.0
The Animal, Landscape and Man Simulation System
landscape.h
Go to the documentation of this file.
1 // Landscape.h
2 //
3 /*
4 *******************************************************************************************************
5 Copyright (c) 2011, Christopher John Topping, University of Aarhus
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or without modification, are permitted provided
9 that the following conditions are met:
10 
11 Redistributions of source code must retain the above copyright notice, this list of conditions and the
12 following disclaimer.
13 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
14 the following disclaimer in the documentation and/or other materials provided with the distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
19 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 ********************************************************************************************************
25 */
26 
27 #define _CRTDBG_MAP_ALLOC
28 
29 #ifndef TLANDSCAPE_H
30 #define TLANDSCAPE_H
31 
32 #include <vector>
33 #include <fstream>
34 
35 // General
36 const int January = 0;
37 const int February = 31;
38 const int March = 59;
39 const int April = 90;
40 const int May = 120;
41 const int June = 151;
42 const int July = 181;
43 const int August = 212;
44 const int September = 243;
45 const int October = 273;
46 const int November = 304;
47 const int December = 334;
48 
49 // m_polymapping is a mapping from polygon numbers into
50 // the list of landscape elements, m_elems.
51 
52 extern class Pesticide *g_pest;
53 
54 class RasterMap;
55 class SkTerritories;
57 class PesticideMap;
61 };
62 
64 
66 {
77 };
78 
81 {
82  int polyref;
83  int geese;
84  int geesesp[gs_foobar];
86  int geesespTimed[gs_foobar];
87  int roostdists[gs_foobar];
88  double openness;
89  double grain;
90  double maize;
91  double grass[gs_foobar]; // Available grass forage is species specific
93  std::string vegtypechr;
94  double vegheight;
95  double digestability;
96  int vegphase;
97  std::string previouscrop;
98  std::string lastsownveg;
99  std::string debugveg;
100 };
101 
103 typedef std::vector<GooseFieldListItem> GooseFieldList;
104 
105 
106 //------------------------------------------------------------------------------
107 
113 {
114  // Version info. Initialized by the constructor.
115  char m_versioninfo[30];
116 
118  //vector<Farm*> m_farms;
120 
122  vector<LE*> m_elems;
123 
126 
130  vector<int> m_polymapping;
131 
134 
135  // For correcting coordinates before modulus operations.
136  // Put here so we saves an indirection when doing inline
137  // function calls.
138  int m_width;
139  int m_height;
144 
151 
152  // For veg area dumps
156 
163 
164 #ifdef __RECORDFARMEVENTS
165  ofstream *m_farmeventfile;
166 #endif
167 
168 public:
169  void FillVegAreaData();
170  inline double GetVegArea(int v) { return l_vegtype_areas[v]; }
171  void DumpVegAreaData(int a_day);
172  void SkylarkEvaluation(SkTerritories* a_skt);
178  int SupplyFarmAnimalCensus(int a_farm_ref, int a_LifeStage);
179  int SupplyVegPhase(int a_poly) {
180  return m_elems[m_polymapping[a_poly]]->GetVegPhase();
181  }
182  void SetPolymapping(int a_index, int a_val) { m_polymapping[a_index] = a_val; }
183  int GetPolymapping(int a_index) { return m_polymapping[a_index]; }
184 #ifdef __RECORDFARMEVENTS
185  void RecordEvent(int a_event, int a_day, int a_year) {
186  (*m_farmeventfile) << a_event << '\t' << a_day << '\t' << a_year << endl;
187  }
188 #endif
189 protected:
191  void GISASCII_Output(string outpfile, int UTMX, int UTMY);
192 // Array for containing the treatment counts.
195  void AddGreenElement( LE *a_green );
197  vector <int>m_PondIndexList;
199  vector <int>m_PondRefsList;
200  /*
201  void RenumberPolys(bool a_checkvalid);
202  */
203  void ReadPolys(const char *a_polyfile);
205  void ReadPolys2(const char *a_polyfile);
206  void PolysValidate(bool a_exit_on_invalid);
207  bool PolysRemoveInvalid( void );
208  void PolysDump( const char *a_filename );
209  void DumpMap( const char *a_filename );
210  void ConsolidatePolys( void );
211  void CountMapSquares(void);
212  void PolysRenumber(void);
214  { // Rebuild m_polymapping.
215  unsigned int sz = (int)m_elems.size();
216  for (unsigned int i = 0; i < sz; i++)
217  {
218  m_polymapping[m_elems[i]->GetMapIndex()] = i;
219  }
220  }
221  void ForceArea(void);
222  void ChangeMapMapping( void );
225  void RemoveMissingValues();
226  void TestCropManagement( void ); // Optional, configurable.
227  void VegDump(int x,int y);
228  void EventDump(int x,int y, int x2, int y2);
229  void EventDumpPesticides( int x1, int y1 );
231  void DegreesDump();
232  bool BorderNeed( TTypesOfLandscapeElement a_letype );
233  void BorderAdd(LE* a_field, TTypesOfLandscapeElement a_type);
234  void BorderRemoval( void );
236  int RemoveSmallPolygons( void );
238  void CreatePondList();
239  //void OrchardBorderAdd ( LE* a_field );
240  void UnsprayedMarginAdd ( LE* a_field );
241  void UnsprayedMarginScan( LE* a_field, int a_width );
242  void BorderScan( LE* a_field, int a_width );
243  bool BorderTest( int a_fieldpoly, int a_borderpoly, int a_x, int a_y );
244  bool StepOneValid( int a_polyindex, int a_x, int a_y, int step );
245  bool UMarginTest( int a_fieldpoly, int a_borderpoly,int a_x, int a_y, int a_width );
246  bool FindValidXY(int a_field, int &a_x, int &a_y);
247  bool BorderStep(int a_fieldpoly, int a_borderpoly, int* a_x, int* a_y);
248  bool BorderStep(int a_fieldpoly, int a_borderpoly, APoint* a_coord);
249  // int BorderJump( int a_add );
250 
252  bool BeetleBankPossible( LE * a_field, TTypesOfLandscapeElement a_tole );
253  void BeetleBankAdd(int x, int y, int angle, int length , LE* a_field, TTypesOfLandscapeElement a_tole);
254  bool FindFieldCenter(LE* a_field, int* x, int* y);
255  int FindLongestAxis(int* x, int* y, int* a_length);
256  void AxisLoop(int a_poly, int* a_x, int* a_y, int a_axis);
257  void AxisLoop(int a_poly, APoint* a_cor, int a_axis);
258  void AxisLoopLtd(int a_poly, APoint* a_cor, int a_axis, int a_limit);
259  // List of private methods and member elements, which are needed
260  // when adding artificial hedgebanks. Forget I did this. One should
261  // never store what is essentially local variables within the main
262  // class definition.
263  vector<int> hb_hedges;
264  vector<LE*> hb_new_hbs;
265 
266  int m_x_add[ 8 ];
267  int m_y_add[ 8 ];
268  int* hb_map;
269  int hb_width;
271  int hb_size;
279 
280  void hb_Add( void );
281  void hb_AddNewHedgebanks( int a_orig_poly_num );
282  int hb_StripingDist( void );
283  void hb_GenerateHBPolys( void );
284  void hb_FindHedges( void );
285  bool hb_FindBoundingBox( int a_poly_num );
286  void hb_UpPolyNumbers( void );
287  void hb_ClearPolygon( int a_poly_num );
288  void hb_PaintBorder( int a_color );
289  bool hb_MapBorder( int a_x, int a_y );
290  bool hb_HasOtherNeighbour( int a_x, int a_y );
291  bool hb_PaintWhoHasNeighbourColor( int a_neighbour_color,
292  int a_new_color );
293  bool hb_HasNeighbourColor( int a_x, int a_y,
294  int a_neighbour_color );
295  void hb_MarkTopFromLocalMax( int a_color );
296  void hb_MarkTheBresenhamWay( void );
297  int hb_MaxUnpaintedNegNeighbour( int a_x, int a_y );
298  void hb_ResetColorBits( void );
299  void hb_RestoreHedgeCore( int a_orig_poly_number );
300  void hb_DownPolyNumbers( void );
301  void hb_Cleanup( void );
302 
303  //#define HB_TESTING
304 
305  void DumpMapGraphics( const char *a_filename );
306 
307 #ifdef HB_TESTING
308  void hb_dump_map( int a_beginx, int a_width,
309  int a_beginy, int a_height,
310  char* a_filename,
311  bool a_high_numbers );
312  int hb_dump_color( int a_x, int a_y,
313  bool a_high_numbers );
314 #endif
315 
316  // The pesticide engine should I spray flag
318  // For the LE signal loop.
320 
321  void DumpTreatCounters( const char* a_filename );
322 
324 
325 public:
326  ~Landscape( void );
327  Landscape( void );
328  //** \brief Things to do when closing the simulation */
330  // Tick() and TurnTheWorld() are identical, the last one is retained
331  // for historical reasons.
332  void Tick( void );
333  void TurnTheWorld( void );
334 
336  int HowManyPonds() { return int(m_PondIndexList.size()); }
338  int SupplyRandomPondIndex();
340  int SupplyRandomPondRef();
342  int SupplyPondIndex(int a_pondref) {
343  for (int i = 0; i < m_PondIndexList.size(); i++) {
344  if (m_PondRefsList[i] == a_pondref) return m_PondIndexList[i];
345  }
346  return -1;
347  }
349  void SetMaleNewtPresent(int a_InPondIndex) { m_elems[a_InPondIndex]->SetMaleNewtPresent(true); }
351  bool SupplyMaleNewtPresent(int a_InPondIndex) { return m_elems[a_InPondIndex]->IsMaleNewtPresent(); }
352  Farm* SupplyFarmPtr(int a_owner) { return m_FarmManager->GetFarmPtr(a_owner); }
354 
356 
358 
359  double SupplyVegDigestabilityVector( unsigned int a_index );
360  double SupplyVegDigestability( int a_polyref );
361  double SupplyVegDigestability( int a_x, int a_y );
362 
363  double SupplyVegHeightVector( unsigned int a_index );
364  double SupplyVegHeight( int a_polyref );
365  double SupplyVegHeight( int a_x, int a_y );
366 
367  double SupplyVegBiomassVector( unsigned int a_index );
368  double SupplyVegBiomass( int a_polyref );
369  double SupplyVegBiomass( int a_x, int a_y );
370 
371  int SupplyVegDensity( int a_polyref );
372  int SupplyVegDensity( int a_x, int a_y );
373 
374  double SupplyWeedBiomass( int a_polyref );
375  double SupplyWeedBiomass( int a_x, int a_y );
376 
377  PollenNectarQuality SupplyPollen(int a_polyref) { return m_elems[a_polyref]->GetPollen(); };
378  PollenNectarQuality SupplyPollen(int a_x, int a_y) { return m_elems[m_land->Get(a_x, a_y)]->GetPollen(); };
379  double SupplyTotalPollen(int a_polyref) { return m_elems[a_polyref]->GetTotalPollen(); };
380  double SupplyTotalPollen(int a_x, int a_y) { return m_elems[m_land->Get(a_x, a_y)]->GetTotalPollen(); };
381  PollenNectarQuality SupplyNectar(int a_polyref) { return m_elems[a_polyref]->GetNectar(); };
382  PollenNectarQuality SupplyNectar(int a_x, int a_y) { return m_elems[m_land->Get(a_x, a_y)]->GetNectar(); };
383  double SupplyTotalNectar(int a_polyref) { return m_elems[a_polyref]->GetTotalNectar(); };
384  double SupplyTotalNectar(int a_x, int a_y) { return m_elems[m_land->Get(a_x, a_y)]->GetTotalNectar(); };
385 
386  bool SupplySkScrapes(int a_polyref);
387 
388  bool SupplyVegPatchy( int a_polyref );
389  bool SupplyVegPatchy( int a_x, int a_y );
390 
391  double SupplyGreenBiomass( int a_polyref );
392  double SupplyGreenBiomass( int a_x, int a_y );
393 
394  double SupplyDeadBiomass( int a_polyref );
395  double SupplyDeadBiomass( int a_x, int a_y );
396 
397  double SupplyLAGreen( int a_polyref );
398  double SupplyLAGreen( int a_x, int a_y );
399  double SupplyLATotal( int a_x, int a_y );
400 
401  double SupplyVegCover( int a_polyref );
402  double SupplyVegCoverVector( unsigned int a_index );
403  double SupplyVegCover( int a_x, int a_y );
404  TTypesOfVegetation SupplyLastSownVeg(int a_polyref);
405  TTypesOfVegetation SupplyLastSownVeg(int a_x, int a_y);
406  TTypesOfVegetation SupplyLastSownVegVector(unsigned int a_index);
407 
408  double SupplyInsects( int a_polyref );
409  double SupplyInsects( int a_x, int a_y );
411  bool SubtractPondLarvalFood(double a_food, int a_polyrefindex);
413  void CheckForPesticideRecord(LE * a_field, TTypesOfPesticideCategory a_pcide);
415  double SupplyRodenticide(int a_x, int a_y);
419  double SupplyPesticide(int a_x, int a_y, PlantProtectionProducts a_ppp);
421  bool SupplyOverspray(int a_x, int a_y);
423  double SupplyPesticideP(int a_x, int a_y, PlantProtectionProducts a_ppp);
425  double SupplyPesticideS(int a_x, int a_y, PlantProtectionProducts a_ppp);
427  double SupplyPesticide(int a_polyref, PlantProtectionProducts a_ppp);
429  double SupplyPesticideP(int a_polyref, PlantProtectionProducts a_ppp);
431  double SupplyPesticideS(int a_polyref, PlantProtectionProducts a_ppp);
437  void ResetGrainAndMaize();
439  void CalculateOpenness(bool a_realcalc);
441  void WriteOpenness( void );
443  void ReadOpenness( void );
445  int CalulateFieldOpennessCentroid(int a_pref);
447  int CalulateFieldOpennessAllCells(int a_pref);
449  int LineHighTest(int a_cx, int a_cy, double a_offsetx, double a_offsety);
451  int SupplyOpenness(int a_poly) { return m_elems[m_polymapping[ a_poly ]]->GetOpenness(); }
453  int SupplyOpenness(int a_x, int a_y) { return m_elems[ m_land->Get( a_x, a_y )]->GetOpenness(); }
455  bool SupplyLEHigh(int a_x, int a_y) { return m_elems[ m_land->Get( a_x, a_y ) ]->GetHigh(); }
457  polylist* SupplyLargeOpenFieldsNearXY(int x, int y, int range, int a_openness );
458 
460  int SupplySoilType( int a_x, int a_y ) {
461  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilType( );
462  }
464  int SupplySoilTypeR( int a_x, int a_y ) {
465  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilTypeR( );
466  }
467 
468  APoint SupplyCentroid( int a_polyref );
469  APoint SupplyCentroidIndex( int a_polyrefindex );
470  int SupplyCentroidX( int a_polyref ) {
471  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroidX();
472  }
473  int SupplyCentroidY( int a_polyref ) { return m_elems[m_polymapping[ a_polyref ]]->GetCentroidY(); }
474  int SupplyCentroidX( int a_x, int a_y ) { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidX(); }
475  int SupplyCentroidY( int a_x, int a_y ) { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidY(); }
476 
477  int SupplyFarmIntensity( int a_x, int a_y );
478  int SupplyFarmIntensity( int a_polyref );
479  int SupplyFarmIntensityI( int a_polyindex );
480 
482  TTypesOfLandscapeElement SupplyElementType( int a_x, int a_y );
483  TTypesOfLandscapeElement SupplyElementTypeCC( int a_x, int a_y );
484 
485  int SupplyCountryDesig( int a_x, int a_y );
486 
487  int SupplyElementSubType( int a_polyref );
488  int SupplyElementSubType( int a_x, int a_y );
489 
490  TTypesOfVegetation SupplyVegType(int a_x, int a_y);
491  TTypesOfVegetation SupplyVegType(int polyref);
492  TTypesOfVegetation SupplyVegTypeVector( unsigned int a_index );
493  int SupplyGrazingPressureVector(unsigned int a_index);
494  int SupplyGrazingPressure(int a_polyref);
495  int SupplyGrazingPressure(int a_x, int a_y);
496  bool SupplyIsCereal(int a_polyref);
497  bool SupplyIsMatureCereal(int a_polyref);
498  bool SupplyIsGrass(int a_polyref);
499  bool SupplyIsGrass2(TTypesOfVegetation a_vege_type);
500  bool SupplyIsCereal2(TTypesOfVegetation a_vege_type);
501  bool SupplyHasTramlines( int a_x, int a_y );
502  bool SupplyHasTramlines( int a_polyref );
503  bool SupplyJustMownVector( unsigned int a_index );
504  bool SupplyJustMown( int a_polyref );
505  int SupplyJustSprayedVector( unsigned int a_index );
506  int SupplyJustSprayed( int a_polyref );
507  int SupplyJustSprayed( int a_x, int a_y );
508  int SupplyTreeAge(int a_Polyref);
509  int SupplyTreeAge(int /* a_x */, int /* a_y */) {return 0;}
510  int SupplyVegAge(int a_Polyref);
511  int SupplyVegAge(int a_x, int a_y);
512  int SupplyNumberOfFarms();
513  int SupplyFarmOwner( int a_x, int a_y );
514  int SupplyFarmOwner( int a_polyref );
515  int SupplyFarmOwnerIndex( int a_x, int a_y );
516  int SupplyFarmOwnerIndex( int a_polyref );
517 
518  TTypesOfFarm SupplyFarmType( int a_polyref );
519  TTypesOfFarm SupplyFarmType( int a_x, int a_y );
520  TTypesOfOptFarms SupplyOptFarmType (int a_x, int a_y); //AM, 270813
521  int SupplyFarmArea( int a_polyref );
522  double SupplyPolygonAreaVector( int a_polyref );
523  double SupplyPolygonArea( int a_polyref ) { return m_elems[ m_polymapping[ a_polyref ]]->GetArea(); }
524 
528  void SetBirdSeedForage(int a_polyref, double a_fooddensity)
529  {
530  m_elems[m_polymapping[a_polyref]]->SetBirdSeed(a_fooddensity);
531  }
535  void SetBirdMaizeForage( int a_polyref, double a_fooddensity ) {
536  m_elems[ m_polymapping[ a_polyref ] ]->SetBirdMaize( a_fooddensity );
537  }
541  double SupplyGooseGrazingForageH( double a_height, GooseSpecies a_goose)
542  {
548  if (a_goose == gs_Pinkfoot)
549  {
550  return m_GooseIntakeRateVSVegetationHeight_PF->GetY( a_height );
551  }
552  if (a_goose == gs_Barnacle)
553  {
554  if (a_height == 0.0) return 0.0;
555  else return m_GooseIntakeRateVSVegetationHeight_BG->GetY(a_height);
556  }
557  if (a_goose == gs_Greylag)
558  {
560  }
561  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
562  exit(1);
563  }
564 
567  double SupplyGooseGrazingForageH(int a_polygon, GooseSpecies a_goose)
568  {
574  if (a_goose == gs_Pinkfoot)
575  {
576  return m_GooseIntakeRateVSVegetationHeight_PF->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
577  }
578  if (a_goose == gs_Barnacle)
579  {
580  return m_GooseIntakeRateVSVegetationHeight_BG->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
581  }
582  if (a_goose == gs_Greylag)
583  {
584  return m_GooseIntakeRateVSVegetationHeight_GL->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
585  }
586  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
587  exit(1);
588  }
596  double GetActualGooseGrazingForage(int a_x, int a_y, GooseSpecies a_goose)
597  {
598  return m_elems[m_land->Get(a_x, a_y)]->GetGooseGrazingForage(a_goose);
599  }
607  double GetActualGooseGrazingForage(int a_polygon, GooseSpecies a_goose)
608  {
609  return m_elems[m_polymapping[a_polygon]]->GetGooseGrazingForage(a_goose);
610  }
614  double SupplyBirdSeedForage(int a_polyref)
615  {
616  return m_elems[m_polymapping[a_polyref]]->GetBirdSeed();
617  }
621  double SupplyBirdSeedForage(int a_x, int a_y)
622  {
623  return m_elems[m_polymapping[m_land->Get(a_x, a_y)]]->GetBirdSeed();
624  }
628  double SupplyBirdMaizeForage(int a_polyref) {
629  return m_elems[m_polymapping[a_polyref]]->GetBirdMaize();
630  }
634  bool SupplyInStubble(int a_polyref) {
635  return m_elems[m_polymapping[a_polyref]]->GetStubble();
636  }
640  double SupplyBirdMaizeForage( int a_x, int a_y ) {
641  return m_elems[ m_land->Get( a_x, a_y ) ]->GetBirdMaize();
642  }
647  void RecordGooseNumbers(int a_poly, int a_number);
652  void RecordGooseSpNumbers(int a_poly, int a_number, GooseSpecies a_goose);
657  void RecordGooseNumbersTimed(int a_poly, int a_number);
662  void RecordGooseSpNumbersTimed(int a_poly, int a_number, GooseSpecies a_goose);
666  void RecordGooseRoostDist(int a_polyref, int a_dist, GooseSpecies a_goose);
670  void GrazeVegetation( int a_poly, double a_forage ) {
671  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetation( a_forage, true );
672  }
676  void GrazeVegetationTotal( int a_poly, double a_forage ) {
677  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetationTotal( a_forage );
678  }
682  int GetGooseNumbers(int a_poly);
686  int GetQuarryNumbers(int a_poly);
690  int GetGooseNumbers(int a_x, int a_y);
691 
692  int SupplyLastTreatment( int a_polyref, int *a_index );
693  int SupplyLastTreatment( int a_x, int a_y, int *a_index );
694  double GetHareFoodQuality(int a_polygon);
695 
696  // Weather data.
697 
698  // Energizer Bunny Edition. Use these if at all possible.
699  // Returns the requested data for *today* (whatever that is).
700  double SupplyGlobalRadiation( );
701  double SupplyGlobalRadiation( long a_date );
702  double SupplyRain( void );
703  double SupplyTemp( void );
704  double SupplyHumidity(void);
705  double SupplyMeanTemp(long a_date, unsigned int a_period);
706  double SupplyWind( void );
707  int SupplyWindDirection( void );
708  double SupplySnowDepth( void );
709  bool SupplySnowcover( void );
710  int SupplyDaylength( void );
711 
712  // *Yawn*! These work for all dates as expected, but
713  // they are slow, slow, slzzz....
714  double SupplyRain( long a_date );
715  double SupplyTemp( long a_date );
716  double SupplyWind( long a_date );
717  double SupplyDayDegrees(int a_polyref);
718  double SupplyRainPeriod( long a_date, int a_period );
719  double SupplyWindPeriod( long a_date, int a_period );
720  double SupplyTempPeriod(long a_date, int a_period);
721  // double SupplyGlobalRadiation( a_date );
722 
723  // Warning: Known spooky behaviour, but it works, sort of...
724  bool SupplySnowcover( long a_date );
725 
726  // Misc.
728  if ((a_tole == tole_Field)
729  || (a_tole == tole_Orchard)
730  || (a_tole == tole_PermanentSetaside)
731  || (a_tole == tole_PermPasture)
732  || (a_tole == tole_PermPastureLowYield)
733  || (a_tole == tole_PermPastureTussocky)
734  || (a_tole == tole_PermPastureTussockyWet)
735  || (a_tole == tole_Vildtager)
736  || (a_tole == tole_YoungForest)
737  || (a_tole == tole_WoodyEnergyCrop)
738  ) return true;
739  return false;
740  }
741  int SupplyPolyRef( int a_x, int a_y );
742  int SupplyPolyRefIndex( int a_x, int a_y );
743  int SupplyPolyRefCC( int a_x, int a_y );
744  int SupplySimAreaWidth( void );
745  int SupplySimAreaHeight( void );
746  int SupplySimAreaMaxExtent( void );
748  int SupplyDaylength( long a_date );
749  int SupplyDayInYear( void );
750  int SupplyHour( void );
751  int SupplyMinute( void );
752  unsigned int SupplyNumberOfPolygons( void );
754  SupplyElementTypeFromVector( unsigned int a_index );
755  int SupplyPolyRefVector( unsigned int a_index );
756  int SupplyPesticideCell(int a_polyref);
757  int SupplyValidX(int a_polyref);
758  int SupplyValidY(int a_polyref);
759 
761  double SupplyPondPesticide(int a_poly_index) { return dynamic_cast<Pond*>(m_elems[a_poly_index])->SupplyPondPesticide(); }
762 
764  void CorrectCoords(int &x, int &y);
766  APoint CorrectCoordsPt(int x, int y);
768  void CorrectCoordsPointNoWrap( APoint &a_pt );
769  int CorrectWidth( int x );
770  int CorrectHeight( int y );
771  void SetPolyMaxMinExtents( void );
772  void CalculateCentroids( void );
773  void DumpCentroids( void );
776  void CentroidSpiralOut(int a_polyref, int &a_x, int &a_y);
777  //void CentroidSpiralOutBlocks(int a_polyref, int &a_x, int &a_y);
778  const char* SupplyVersion(void) { return m_versioninfo; }
779 
780  // Debugging, warning and configuration methods.
781  void DumpPublicSymbols( const char *a_dumpfile,
782  CfgSecureLevel a_level ) {
783  g_cfg->DumpPublicSymbols( a_dumpfile, a_level );
784  }
785  void DumpAllSymbolsAndExit( const char *a_dumpfile ) {
786  g_cfg->DumpAllSymbolsAndExit( a_dumpfile );
787  }
788  bool ReadSymbols( const char *a_cfgfile ) {
789  return g_cfg->ReadSymbols( a_cfgfile );
790  }
791  void DumpMapInfoByArea( const char *a_filename,
792  bool a_append,
793  bool a_dump_zero_areas,
794  bool a_write_veg_names
795  );
796 
797  void Warn( std::string a_msg1, std::string a_msg2 );
798 
799  // This is really, really naughty, but for the sake of efficiency...
800  // SupplyMagicMapP( int a_x, int a_y ) returns a pointer to the map
801  // at position x, y. The value found through it is an internal magic
802  // number from the landscape simulator, that uniquely identifies a
803  // polygon. It is however not the polygon number. To find that one
804  // must convert the magic number via
805  // MagicMapP2PolyRef( int a_magic ).
806  //
807  int* SupplyMagicMapP( int a_x, int a_y );
808  int MagicMapP2PolyRef( int a_magic );
809 
810 // For the Roe Deer
811  int SupplyRoadWidth(int,int) {return 0;}
812  double SupplyTrafficLoad( int a_x, int a_y );
813  double SupplyTrafficLoad( int a_polyref );
814  int SupplyTreeHeight(int,int) {return 0;}
815  int SupplyUnderGrowthWidth(int,int) {return 0;}
816  int SupplyTreeHeight(int /* polyref */ ) {return 0;}
817  int SupplyUnderGrowthWidth(int /* polyref */ ) {return 0;}
818 
819 // For the debugging programmer.
820  long SupplyGlobalDate( void );
821  int SupplyYear( void );
822  int SupplyYearNumber( void );
823  int SupplyMonth( void );
824  int SupplyDayInMonth( void );
826  double SupplyNightProp() { return 1.0-g_date->GetDaylightProportion(); }
827 
828 // General use. Introduced 1/12-2003.
829 // Reset internal loop counter.
830  void SupplyLEReset( void );
831 // Returns -1 at end-of-loop, polygon ref otherwise.
832  int SupplyLENext( void );
833  int SupplyLECount( void );
834  LE_Signal SupplyLESignal( int a_polyref );
835  void SetLESignal( int a_polyref, LE_Signal a_signal );
836 
837  void IncTreatCounter( int a_treat );
838 
840  TTypesOfVegetation TranslateVegTypes(int VegReference);
841  LE* SupplyLEPointer( int a_polyref );
842 
844  int BackTranslateVegTypes(TTypesOfVegetation VegReference);
845 
846  std::string EventtypeToString( int a_event );
847  std::string PolytypeToString( TTypesOfLandscapeElement a_le_type );
848  std::string VegtypeToString( TTypesOfVegetation a_veg );
849 
850 
851  /* *********************** Bee Helper Methods *********************** */
853  void InitOsmiaBeeNesting();
854 
857  for (unsigned int s = 0; s < m_elems.size(); s++) m_elems[s]->UpdateOsmiaNesting();
858  }
859 
861  bool SupplyOsmiaNest(int a_x, int a_y) {
862  return m_elems[m_land->Get(a_x, a_y)]->GetOsmiaNest();
863  }
864 
866  void IncOsmiaNest(int a_x, int a_y) {
867  m_elems[m_land->Get(a_x, a_y)]->IncOsmiaNesting();
868  }
869 
871  void ReleaseOsmiaNest(int a_x, int a_y) {
872  m_elems[m_land->Get(a_x, a_y)]->ReleaseOsmiaNest();
873  }
874  /* ********************* End Bee Helper Methods ********************* */
875  // /** \brief Reset all polygons natural grazing level to zero */
876  // void ResetAllVoleGrazing( void )
877  // {
878  // for ( unsigned int i=0; i<m_elems.size(); i++ ) m_elems[i]->ResetVoleGrazing();
879  // }
880  // /** \brief Inc volegrazing at x,y */
881  // void IncVoleGrazing(int a_x, int a_y) { m_elems[ m_land->Get( a_x, a_y ) ]->AddVoleGrazing(1); }
882  // /** \brief Get volegrazing at x,y */
883  // double SupplyVoleGrazingDensityVector(unsigned int a_index) { return m_elems[ a_index ]->GetVoleGrazingDensity(); }
884  // /** \brief Calculate all vole grazing densities */
885  // void CalcAllVoleGrazingDensity()
886  // {
887  //for ( unsigned int i=0; i<m_elems.size(); i++ ) { m_elems[i]->CalcVoleGrazingDensity(); }
888  // }
889 
890 protected:
891 /*
892  **CJT** 19/07/2018 these appear not to be used
893  void MakeCluster(void);
894  void ReadInput(int* , int* , int* , APoint*);
895  APoint RandomLocation(void);
896  APoint GetNextSeed(int);
897  int AddToClusterList(int* , int* , int*, int*, int*);
898  void ModifyPolyRef(int* );
899 */
900 };
901 
902 
903 extern Landscape *g_map;
904 
905 inline void Landscape::TurnTheWorld( void )
906 {
907  Tick();
908 }
909 
910 // We are interested in *speed*. Inlining all the lookup functions
911 // here and in the associated classes will cost us very little
912 // but a few KB of memory.
913 
914 inline double Landscape::SupplyVegDigestabilityVector(unsigned int a_index )
915 {
916  return m_elems[ a_index ]->GetDigestability();
917 }
918 
919 inline double Landscape::SupplyVegDigestability( int a_polyref )
920 {
921  return m_elems[ m_polymapping[ a_polyref ]]->GetDigestability();
922 }
923 
924 
925 inline double Landscape::SupplyVegDigestability( int a_x, int a_y )
926 {
927  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDigestability();
928 }
929 
930 
931 inline double Landscape::SupplyVegHeightVector( unsigned int a_index )
932 {
933  return m_elems[ a_index ]->GetVegHeight();
934 }
935 
936 inline double Landscape::SupplyVegHeight( int a_polyref )
937 {
938  return m_elems[ m_polymapping[ a_polyref ]]->GetVegHeight();
939 }
940 
941 inline double Landscape::SupplyVegHeight( int a_x, int a_y )
942 {
943  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegHeight();
944 }
945 
946 
947 
948 inline double Landscape::SupplyVegBiomassVector( unsigned int a_index )
949 {
950  return m_elems[ a_index ]->GetVegBiomass();
951 }
952 
953 inline double Landscape::SupplyVegBiomass( int a_polyref )
954 {
955  return m_elems[ m_polymapping[ a_polyref ]]->GetVegBiomass();
956 }
957 
958 inline double Landscape::SupplyVegBiomass( int a_x, int a_y )
959 {
960  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegBiomass();
961 }
962 
963 
964 inline double Landscape::SupplyWeedBiomass( int a_polyref )
965 {
966  return m_elems[ m_polymapping[ a_polyref ]]->GetWeedBiomass();
967 }
968 
969 
970 inline double Landscape::SupplyWeedBiomass( int a_x, int a_y )
971 {
972  return m_elems[ m_land->Get( a_x, a_y ) ]->GetWeedBiomass();
973 }
974 
975 inline int Landscape::SupplyVegDensity( int a_polyref )
976 {
977  return m_elems[ m_polymapping[ a_polyref ]]->GetVegDensity();
978 }
979 
980 
981 inline bool Landscape::SupplySkScrapes( int a_polyref )
982 {
983  return m_elems[ m_polymapping[ a_polyref ]]->GetSkScrapes();
984 }
985 
986 inline bool Landscape::SupplyVegPatchy( int a_polyref )
987 {
988  return m_elems[ m_polymapping[ a_polyref ]]->GetVegPatchy();
989 }
990 
991 
992 inline bool Landscape::SupplyVegPatchy( int a_x, int a_y )
993 {
994  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegPatchy();
995 }
996 
997 
998 inline int Landscape::SupplyVegDensity( int a_x, int a_y )
999 {
1000  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegDensity();
1001 }
1002 
1003 
1004 inline double Landscape::SupplyLATotal( int a_x, int a_y )
1005 {
1006  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLATotal();
1007 }
1008 
1009 
1010 inline double Landscape::SupplyLAGreen( int a_x, int a_y )
1011 {
1012  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLAGreen();
1013 }
1014 
1015 
1016 
1017 inline double Landscape::SupplyGreenBiomass( int a_polyref )
1018 {
1019  return m_elems[ m_polymapping[ a_polyref ]]->GetGreenBiomass();
1020 }
1021 
1022 inline double Landscape::SupplyGreenBiomass( int a_x, int a_y )
1023 {
1024  return m_elems[ m_land->Get( a_x, a_y ) ]->GetGreenBiomass();
1025 }
1026 
1027 
1028 
1029 inline double Landscape::SupplyDeadBiomass( int a_polyref )
1030 {
1031  return m_elems[ m_polymapping[ a_polyref ]]->GetDeadBiomass();
1032 }
1033 
1034 inline double Landscape::SupplyDeadBiomass( int a_x, int a_y )
1035 {
1036  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDeadBiomass();
1037 }
1038 
1039 
1040 
1041 inline double Landscape::SupplyLAGreen( int a_polyref )
1042 {
1043  return m_elems[ m_polymapping[ a_polyref ]]->GetLAGreen();
1044 }
1045 
1046 
1047 
1048 inline double Landscape::SupplyVegCover( int a_polyref )
1049 {
1050  return m_elems[ m_polymapping[ a_polyref ]]->GetVegCover();
1051 }
1052 
1053 inline double Landscape::SupplyVegCoverVector( unsigned int a_index )
1054 {
1055  return m_elems[ a_index ]->GetVegCover();
1056 }
1057 
1058 inline double Landscape::SupplyVegCover( int a_x, int a_y )
1059 {
1060  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegCover();
1061 }
1062 
1064 {
1065  return m_elems[a_index]->GetLastSownVeg();
1066 }
1067 
1069 {
1070  return m_elems[m_polymapping[a_polyref]]->GetLastSownVeg();
1071 }
1072 
1074 {
1075  return m_elems[m_land->Get(a_x, a_y)]->GetLastSownVeg();
1076 }
1077 
1078 inline int Landscape::SupplyVegAge(int a_polyref)
1079 {
1080  return m_elems[ m_polymapping[ a_polyref ]]->GetVegAge();
1081 }
1082 
1083 inline int Landscape::SupplyVegAge( int a_x, int a_y )
1084 {
1085  return m_elems[m_land->Get(a_x, a_y)]->GetVegAge();
1086 }
1087 
1088 inline double Landscape::SupplyInsects( int a_polyref )
1089 {
1090  return m_elems[ m_polymapping[ a_polyref ]]->GetInsectPop();
1091 }
1092 
1093 inline double Landscape::SupplyInsects( int a_x, int a_y )
1094 {
1095  return m_elems[ m_land->Get( a_x, a_y ) ]->GetInsectPop();
1096 }
1097 
1098 
1099 inline LE* Landscape::SupplyLEPointer( int a_polyref )
1100 {
1101  return m_elems[ m_polymapping[ a_polyref ]];
1102 }
1103 
1105 {
1106  return m_elems[ a_index ]->GetElementType();
1107 }
1108 
1109 
1111 {
1112  return m_elems[ m_polymapping[ a_polyref ]]->GetElementType();
1113 }
1114 
1116 {
1117  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1118 }
1119 
1120 
1121 inline int Landscape::SupplyElementSubType( int a_polyref )
1122 {
1123  return m_elems[ m_polymapping[ a_polyref ]]->GetSubType();
1124 }
1125 
1126 inline int Landscape::SupplyElementSubType( int a_x, int a_y )
1127 {
1128  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSubType();
1129 }
1130 
1131 
1132 inline int Landscape::SupplyCountryDesig( int a_x, int a_y )
1133 {
1134  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCountryDesignation();
1135 }
1136 
1137 
1140 {
1141  a_x = (a_x + m_width10) % m_width;
1142  a_y = (a_y + m_height10) % m_height;
1143  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1144 }
1145 
1146 
1147 
1149  return m_FarmManager->GetNoFarms();
1150 }
1151 
1152 inline int Landscape::SupplyFarmOwner( int a_x, int a_y ) {
1153  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerFile();
1154 }
1155 
1156 
1157 
1158 inline int Landscape::SupplyFarmOwner( int a_polyref )
1159 {
1160  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerFile();
1161 }
1162 
1163 
1164 
1165 inline int Landscape::SupplyFarmOwnerIndex( int a_x, int a_y )
1166 {
1167  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerIndex();
1168 }
1169 
1170 
1171 
1172 inline int Landscape::SupplyFarmOwnerIndex( int a_polyref )
1173 {
1174  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerIndex();
1175 }
1176 
1177 
1178 
1180 {
1181  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetType();
1182 }
1183 
1184 
1185 
1186 inline TTypesOfFarm Landscape::SupplyFarmType( int a_x, int a_y )
1187 {
1188  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetType();
1189 }
1190 
1192 {
1193  OptimisingFarm * opf;
1194  opf = dynamic_cast<OptimisingFarm*>(m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner());
1195  return opf-> Get_farmType();
1196 }
1197 
1198 
1200 inline double Landscape::SupplyPolygonAreaVector( int a_polyref )
1201 {
1202  return m_elems[ a_polyref ]->GetArea();
1203 }
1204 
1205 
1206 inline int Landscape::SupplyFarmArea( int a_polyref )
1207 {
1208  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetArea();
1209 }
1210 
1211 
1212 
1213 inline TTypesOfVegetation
1214  Landscape::SupplyVegType( int a_polyref )
1215 {
1216  return m_elems[ m_polymapping[ a_polyref ] ]->GetVegType();
1217 }
1218 
1219 inline TTypesOfVegetation
1220  Landscape::SupplyVegTypeVector( unsigned int a_index )
1221 {
1222  return m_elems[ a_index ]->GetVegType();
1223 }
1224 
1225 
1226 
1227 inline int Landscape::SupplyGrazingPressure( int a_polyref )
1228 {
1229  return m_elems[ m_polymapping[ a_polyref ] ]->GetCattleGrazing();
1230 }
1231 
1232 inline int Landscape::SupplyGrazingPressureVector( unsigned int a_index )
1233 {
1234  return m_elems[ a_index ]->GetCattleGrazing();
1235 }
1236 
1237 
1238 
1239 inline int Landscape::SupplyGrazingPressure( int a_x, int a_y )
1240 {
1241  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCattleGrazing();
1242 }
1243 
1244 
1245 
1246 inline bool Landscape::SupplyHasTramlines( int a_polyref )
1247 {
1248  return m_elems[ m_polymapping[ a_polyref ] ]->HasTramlines();
1249 }
1250 
1251 
1252 inline bool Landscape::SupplyHasTramlines( int a_x, int a_y )
1253 {
1254  return m_elems[ m_land->Get( a_x, a_y ) ]->HasTramlines();
1255 }
1256 
1257 
1258 inline bool Landscape::SupplyJustMownVector( unsigned int a_index )
1259 {
1260  return m_elems[ a_index ]->IsRecentlyMown();
1261 }
1262 
1263 inline bool Landscape::SupplyJustMown( int a_polyref )
1264 {
1265  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlyMown();
1266 }
1267 
1268 
1269 
1270 inline int Landscape::SupplyJustSprayedVector( unsigned int a_index )
1271 {
1272  return m_elems[ a_index ]->IsRecentlySprayed();
1273 }
1274 
1275 inline int Landscape::SupplyJustSprayed( int a_polyref )
1276 {
1277  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlySprayed();
1278 }
1279 
1280 inline int Landscape::SupplyJustSprayed( int a_x, int a_y )
1281 {
1282  return m_elems[ m_land->Get( a_x, a_y ) ]->IsRecentlySprayed();
1283 }
1284 
1285 
1286 
1287 inline double Landscape::SupplyTrafficLoad( int a_polyref )
1288 {
1289  return m_elems[ m_polymapping[ a_polyref ] ]->GetTrafficLoad();
1290 }
1291 
1292 
1293 inline double Landscape::SupplyTrafficLoad( int a_x, int a_y )
1294 {
1295  return m_elems[ m_land->Get( a_x, a_y ) ]->GetTrafficLoad();
1296 }
1297 
1298 
1299 
1300 inline bool Landscape::SupplyIsCereal(int a_polyref)
1301 {
1302  return m_elems[m_polymapping[a_polyref]]->IsCereal();
1303 }
1304 
1305 inline bool Landscape::SupplyIsMatureCereal(int a_polyref)
1306 {
1307  return m_elems[m_polymapping[a_polyref]]->IsMatureCereal();
1308 }
1309 
1310 inline bool Landscape::SupplyIsGrass(int a_polyref)
1311 {
1312  return m_elems[ m_polymapping[ a_polyref ] ]->IsGrass();
1313 }
1314 
1315 inline int Landscape::SupplyTreeAge( int /* a_polyref */ )
1316 {
1317  return 1;
1318 }
1319 
1320 inline TTypesOfVegetation
1321  Landscape::SupplyVegType( int a_x, int a_y )
1322 {
1323  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegType();
1324 }
1325 
1326 inline double Landscape::SupplyDayDegrees( int a_polyref )
1327 {
1328  return m_elems[ m_polymapping[ a_polyref ]]->GetDayDegrees();
1329 }
1330 
1331 inline int Landscape::SupplyLastTreatment( int a_polyref, int *a_index )
1332 {
1333  return m_elems[ m_polymapping[ a_polyref ]]->GetLastTreatment( a_index );
1334 }
1335 
1336 inline int Landscape::SupplyLastTreatment( int a_x, int a_y, int *a_index )
1337 {
1338  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLastTreatment( a_index );
1339 }
1340 
1342 {
1343  return g_weather->GetGlobalRadiation( );
1344 }
1345 
1346 inline double Landscape::SupplyGlobalRadiation( long a_date )
1347 {
1348  return g_weather->GetGlobalRadiation( a_date );
1349 }
1350 
1351 inline double Landscape::SupplyRainPeriod( long a_date, int a_period )
1352 {
1353  return g_weather->GetRainPeriod( a_date, a_period );
1354 }
1355 
1356 
1357 
1358 inline double Landscape::SupplyRain( long a_date )
1359 {
1360  return g_weather->GetRain( a_date );
1361 }
1362 
1363 
1364 
1365 inline double Landscape::SupplyRain( void )
1366 {
1367  return g_weather->GetRain();
1368 }
1369 
1370 
1371 
1372 inline double Landscape::SupplyMeanTemp( long a_date, unsigned int a_period )
1373 {
1374  return g_weather->GetMeanTemp( a_date, a_period );
1375 }
1376 
1377 
1378 
1379 inline double Landscape::SupplyTemp( long a_date )
1380 {
1381  return g_weather->GetTemp( a_date );
1382 }
1383 
1384 
1385 
1386 inline double Landscape::SupplyTemp(void)
1387 {
1388  return g_weather->GetTemp();
1389 }
1390 
1391 
1392 
1393 inline double Landscape::SupplyHumidity(void)
1394 {
1395  return g_weather->GetHumidity();
1396 }
1397 
1398 
1399 
1400 inline double Landscape::SupplyWind( long a_date )
1401 {
1402  return g_weather->GetWind( a_date );
1403 }
1404 
1405 inline double Landscape::SupplyWindPeriod( long a_date, int a_period )
1406 {
1407  return g_weather->GetWindPeriod( a_date, a_period );
1408 }
1409 
1410 inline double Landscape::SupplyTempPeriod( long a_date, int a_period )
1411 {
1412  return g_weather->GetTempPeriod( a_date, a_period );
1413 }
1414 
1415 
1416 
1417 inline double Landscape::SupplyWind( void )
1418 {
1419  return g_weather->GetWind();
1420 }
1421 
1422 
1424 {
1425  return g_weather->GetWindDirection();
1426 }
1427 
1428 
1429 
1430 inline bool Landscape::SupplySnowcover( long a_date )
1431 {
1432  return g_weather->GetSnow( a_date );
1433 }
1434 
1435 
1436 
1437 inline bool Landscape::SupplySnowcover( void )
1438 {
1439  return g_weather->GetSnow();
1440 }
1441 
1442 
1443 
1444 inline double Landscape::SupplySnowDepth( void )
1445 {
1446  return g_weather->GetSnowDepth();
1447 }
1448 
1449 
1450 
1451 inline int Landscape::SupplyPolyRefVector( unsigned int a_index )
1452 {
1453  return m_elems[ a_index ]->GetPoly();
1454 }
1455 
1456 
1457 
1458 
1459 
1460 inline unsigned int
1462 {
1463  return (unsigned int) m_elems.size();
1464 }
1465 
1466 
1467 
1468 inline int Landscape::SupplyPesticideCell(int a_polyref)
1469 {
1470  return m_elems[ m_polymapping[ a_polyref ] ]->GetPesticideCell();
1471 }
1472 
1473 
1474 inline int Landscape::SupplyValidX(int a_polyref)
1475 {
1476  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidX();
1477 }
1478 
1479 
1480 
1481 inline int Landscape::SupplyValidY(int a_polyref)
1482 {
1483  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidY();
1484 }
1485 
1486 
1487 
1488 inline int Landscape::SupplyPolyRef( int a_x, int a_y )
1489 {
1490  return m_elems[ m_land->Get( a_x, a_y )]->GetPoly();
1491 }
1492 
1493 inline int Landscape::SupplyPolyRefIndex( int a_x, int a_y )
1494 {
1495  return m_land->Get( a_x, a_y );
1496 }
1497 
1498 
1499 
1500 inline int Landscape::SupplyPolyRefCC( int a_x, int a_y )
1501 {
1502  a_x = (a_x + m_width10) % m_width;
1503  a_y = (a_y + m_height10) % m_height;
1504  return m_elems[ m_land->Get( a_x, a_y )]->GetPoly();
1505 }
1506 
1507 
1508 
1509 inline int* Landscape::SupplyMagicMapP( int a_x, int a_y )
1510 {
1511  return m_land->GetMagicP( a_x, a_y );
1512 }
1513 
1514 
1515 
1516 inline int Landscape::MagicMapP2PolyRef( int a_magic )
1517 {
1518  return m_elems[ a_magic ]->GetPoly();
1519 }
1520 
1521 
1522 
1523 inline int Landscape::SupplyDaylength( long a_date )
1524 {
1525  return g_date->DayLength( a_date );
1526 }
1527 
1528 
1529 
1530 inline int Landscape::SupplyDaylength( void )
1531 {
1532  return g_date->DayLength();
1533 }
1534 
1535 inline void Landscape::CorrectCoords(int &x, int &y)
1536 {
1540  x = (m_width10 + x) % m_width;
1541  y = (m_height10 + y) % m_height;
1542 }
1543 
1545 {
1549  APoint pt;
1550  pt.m_x = (m_width10 + x) % m_width;
1551  pt.m_y = (m_height10 + y) % m_height;
1552  return pt;
1553 }
1554 
1556 {
1560  if (a_pt.m_x >= m_width) a_pt.m_x = m_width - 1;
1561  if (a_pt.m_y >= m_height) a_pt.m_y = m_height - 1;
1562  if (a_pt.m_x < 0) a_pt.m_x = 0;
1563  if (a_pt.m_y < 0) a_pt.m_y = 0;
1564 }
1565 
1566 
1567 inline int Landscape::CorrectWidth( int x )
1568 {
1569  return (m_width10+x)%m_width;
1570 }
1571 
1572 
1573 inline int Landscape::CorrectHeight( int y )
1574 {
1575  return (m_height10+y)%m_height;
1576 }
1577 
1578 
1579 inline void Landscape::Warn( std::string a_msg1, std::string a_msg2 )
1580 {
1581  g_msg->Warn( WARN_MSG, a_msg1, a_msg2 );
1582 }
1586 inline int Landscape::SupplyHour( void ) {
1587  return g_date->GetHour();
1588 }
1592 inline int Landscape::SupplyMinute( void ) {
1593  return g_date->GetMinute();
1594 }
1595 
1596 inline int Landscape::SupplyDayInYear( void )
1597 {
1598  return g_date->DayInYear();
1599 }
1600 
1601 inline int Landscape::SupplyMonth( void )
1602 {
1603  return g_date->GetMonth();
1604 }
1605 
1607 {
1608  return g_date->GetDayInMonth();
1609 }
1610 
1611 inline int Landscape::SupplyYear( void )
1612 {
1613  return g_date->GetYear();
1614 }
1615 
1617 {
1618  return g_date->GetYearNumber();
1619 }
1620 
1621 inline long Landscape::SupplyGlobalDate( void )
1622 {
1623  return g_date->Date();
1624 }
1625 
1626 // Outdated.
1627 //inline int Landscape::SupplyMapSize( void )
1628 //{
1629 // return m_land->Size();
1630 //}
1631 
1633 {
1634  return m_width;
1635 }
1636 
1638 {
1639  return m_height;
1640 }
1641 
1643 {
1644  return m_maxextent;
1645 }
1646 
1649 {
1650  return g_letype->TranslateEleTypes( EleReference );
1651 }
1652 
1653 
1654 inline TTypesOfVegetation
1656 {
1657  return g_letype->TranslateVegTypes( VegReference );
1658 }
1659 
1660 
1661 inline int
1663 {
1664  return g_letype->BackTranslateEleTypes( EleReference );
1665 }
1666 
1667 
1668 inline int
1670 {
1671  return g_letype->BackTranslateVegTypes( VegReference );
1672 }
1673 #endif // LANDSCAPE_H
1674 
class Calendar * g_date
Definition: calendar.cpp:38
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
int m_y
Definition: ALMaSS_Setup.h:56
int m_x
Definition: ALMaSS_Setup.h:55
int GetHour(void)
Definition: calendar.h:71
int GetMonth(void)
Definition: calendar.h:69
long Date(void)
Definition: calendar.h:57
double GetDaylightProportion(void)
Definition: calendar.h:73
int DayLength(void)
Definition: calendar.h:63
int GetYear(void)
Definition: calendar.h:67
int GetDayInMonth(void)
Definition: calendar.h:72
int GetYearNumber(void)
Definition: calendar.h:68
int GetMinute(void)
Definition: calendar.h:70
int DayInYear(void)
Definition: calendar.h:58
void DumpAllSymbolsAndExit(const char *a_dumpfile)
Definition: configurator.cpp:601
bool ReadSymbols(const char *a_cfgfile)
Definition: configurator.cpp:201
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
Definition: configurator.cpp:590
virtual double GetY(double a_X)
Definition: CurveClasses.cpp:73
The base class for all farm types.
Definition: farm.h:768
The Farm Manager class.
Definition: farm.h:1707
int GetNoFarms()
Definition: farm.h:1900
Farm * GetFarmPtr(int a_owner)
Returns the pointer to a farm with a specific number.
Definition: farm.h:1766
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: elements.cpp:3610
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2995
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: elements.cpp:3345
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: elements.cpp:3088
Definition: elements.h:81
The landscape class containing all environmental and topographical data.
Definition: landscape.h:113
void CorrectCoordsPointNoWrap(APoint &a_pt)
Function to prevent wrap around errors with co-ordinates using a APoint.
Definition: landscape.h:1555
bool m_NeedOpennessCalculation
a flag to ensure openness calculation on object construction
Definition: landscape.h:148
int hb_core_pixels
Definition: landscape.h:275
int SupplyJustSprayedVector(unsigned int a_index)
Definition: landscape.h:1270
TTypesOfVegetation SupplyLastSownVegVector(unsigned int a_index)
Definition: landscape.h:1063
int HowManyPonds()
Returns the number of ponds in the landscape.
Definition: landscape.h:336
void GrazeVegetationTotal(int a_poly, double a_forage)
Removes grazing forage from a poly and divides this out per m2.
Definition: landscape.h:676
int m_height10
Definition: landscape.h:141
PollenNectarQuality SupplyPollen(int a_polyref)
Definition: landscape.h:377
int SupplyYearNumber(void)
Definition: landscape.h:1616
void ChangeMapMapping(void)
Definition: Landscape.cpp:2130
bool IsFieldType(TTypesOfLandscapeElement a_tole)
Definition: landscape.h:727
void VegDump(int x, int y)
Definition: Landscape.cpp:1644
int m_LargestPolyNumUsed
Definition: landscape.h:194
long SupplyGlobalDate(void)
Definition: landscape.h:1621
int m_width
Definition: landscape.h:138
void TestCropManagement(void)
void SkylarkEvaluation(SkTerritories *a_skt)
Definition: Landscape.cpp:3025
bool m_DoMissingPolygonsManipulations
Definition: landscape.h:150
double SupplyDayDegrees(int a_polyref)
Definition: landscape.h:1326
int m_height
Definition: landscape.h:139
double SupplyHumidity(void)
Definition: landscape.h:1393
bool hb_MapBorder(int a_x, int a_y)
Definition: hedgebanks.cpp:325
APoint SupplyCentroid(int a_polyref)
Definition: Landscape.cpp:766
int hb_min_y
Definition: landscape.h:273
int SupplySimAreaMaxExtent(void)
Definition: landscape.h:1642
int SupplyPolyRefCC(int a_x, int a_y)
Definition: landscape.h:1500
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: landscape.h:1669
void hb_GenerateHBPolys(void)
Definition: hedgebanks.cpp:180
TTypesOfLandscapeElement SupplyElementTypeCC(int a_x, int a_y)
Definition: landscape.h:1139
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
double SupplyDeadBiomass(int a_polyref)
Definition: landscape.h:1029
bool SupplyIsMatureCereal(int a_polyref)
Definition: landscape.h:1305
vector< int > m_PondRefsList
List of pond polyrefs.
Definition: landscape.h:199
double SupplyVegHeightVector(unsigned int a_index)
Definition: landscape.h:931
int RemoveSmallPolygons(void)
Removes small polygons from the map.
Definition: Landscape.cpp:2184
double SupplyTemp(void)
Definition: landscape.h:1386
int SupplyDaylength(void)
Definition: landscape.h:1530
void RecordGooseNumbers(int a_poly, int a_number)
This records the number of geese on the polygon the day before. To prevent lots of unnecessary cleari...
Definition: Landscape.cpp:3328
void UnsprayedMarginScan(LE *a_field, int a_width)
Definition: Landscape.cpp:2638
void RecordGooseSpNumbersTimed(int a_poly, int a_number, GooseSpecies a_goose)
This records the number of geese of each species on the polygon the day before at a predefined time....
Definition: Landscape.cpp:3363
void BorderScan(LE *a_field, int a_width)
Definition: Landscape.cpp:2365
void BuildingDesignationCalc()
used to calculate whether a building is rural or town - for rodenticide use
Definition: Landscape.cpp:3287
double SupplyTotalNectar(int a_polyref)
Definition: landscape.h:383
vector< LE * > hb_new_hbs
Definition: landscape.h:264
double SupplyWindPeriod(long a_date, int a_period)
Definition: landscape.h:1405
void hb_RestoreHedgeCore(int a_orig_poly_number)
Definition: hedgebanks.cpp:311
int SupplyVegDensity(int a_polyref)
Definition: landscape.h:975
double SupplyVegDigestabilityVector(unsigned int a_index)
Definition: landscape.h:914
int SupplyCountryDesig(int a_x, int a_y)
Definition: landscape.h:1132
void EventDump(int x, int y, int x2, int y2)
Definition: Landscape.cpp:1697
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:119
polylist * SupplyLargeOpenFieldsNearXY(int x, int y, int range, int a_openness)
Returns a pointer to a list of polygonrefs to large open fields within a range of location x,...
Definition: Landscape.cpp:782
double SupplyVegCover(int a_polyref)
Definition: landscape.h:1048
bool SupplyInStubble(int a_polyref)
Returns whether its cereal.
Definition: landscape.h:634
bool FindFieldCenter(LE *a_field, int *x, int *y)
Definition: Landscape.cpp:2799
bool SupplyJustMown(int a_polyref)
Definition: landscape.h:1263
void IncTreatCounter(int a_treat)
Definition: Landscape.cpp:3575
double SupplyWind(void)
Definition: landscape.h:1417
void IncOsmiaNest(int a_x, int a_y)
Reopen the osmia nest here
Definition: landscape.h:866
int CalulateFieldOpennessAllCells(int a_pref)
Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles...
Definition: Landscape.cpp:401
void hb_PaintBorder(int a_color)
Definition: hedgebanks.cpp:429
void GrazeVegetation(int a_poly, double a_forage)
Removes grazing forage from a poly per m2.
Definition: landscape.h:670
bool SupplyOsmiaNest(int a_x, int a_y)
Find out whether an osmia nest can be made here.
Definition: landscape.h:861
void SetThePopManager(Population_Manager *a_ptr)
Set the pointer to the current main population manager.
Definition: landscape.h:177
PesticideMap * m_PesticideMap
For specialised pesticide recording.
Definition: landscape.h:133
bool CIPELandscapeMaker()
double GetHareFoodQuality(int a_polygon)
Definition: Landscape.cpp:3403
int SupplyCentroidY(int a_polyref)
Definition: landscape.h:473
int SupplyFarmIntensityI(int a_polyindex)
Definition: Landscape.cpp:751
bool BorderStep(int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
Definition: Landscape.cpp:2479
int SupplyGrazingPressureVector(unsigned int a_index)
Definition: landscape.h:1232
int hb_MaxUnpaintedNegNeighbour(int a_x, int a_y)
Definition: hedgebanks.cpp:548
double SupplyGooseGrazingForageH(int a_polygon, GooseSpecies a_goose)
Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by number ba...
Definition: landscape.h:567
TTypesOfOptFarms SupplyOptFarmType(int a_x, int a_y)
Definition: landscape.h:1191
double GetVegArea(int v)
Definition: landscape.h:170
int SupplyPondIndex(int a_pondref)
Returns the index of a pond based on pondref or -1 if not found.
Definition: landscape.h:342
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
Definition: landscape.h:161
void CalculateOpenness(bool a_realcalc)
Causes openness to be calulated and stored for all polygons.
Definition: Landscape.cpp:322
TTypesOfFarm SupplyFarmType(int a_polyref)
Definition: landscape.h:1179
int SupplyUnderGrowthWidth(int, int)
Definition: landscape.h:815
double SupplyPesticide(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets total pesticide for a location.
Definition: Landscape.cpp:586
vector< int > m_polymapping
Definition: landscape.h:130
void CountMapSquares(void)
Definition: Landscape.cpp:2040
int SupplyFarmIntensity(int a_x, int a_y)
Definition: Landscape.cpp:756
void AxisLoop(int a_poly, int *a_x, int *a_y, int a_axis)
Definition: Landscape.cpp:2938
void FillVegAreaData()
Definition: Landscape.cpp:3641
int GetGooseNumbers(int a_poly)
This returns the number of geese on the polygon the day before.
Definition: Landscape.cpp:3383
int SupplyTreeHeight(int, int)
Definition: landscape.h:814
void SupplyLEReset(void)
Definition: Landscape.cpp:3551
double SupplyGlobalRadiation()
Definition: landscape.h:1341
double SupplyInsects(int a_polyref)
Definition: landscape.h:1088
double SupplyWeedBiomass(int a_polyref)
Definition: landscape.h:964
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:936
double GetActualGooseGrazingForage(int a_polygon, GooseSpecies a_goose)
Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,...
Definition: landscape.h:607
void DumpMapGraphics(const char *a_filename)
Definition: Landscape.cpp:3599
void TurnTheWorld(void)
Definition: landscape.h:905
int hb_min_x
Definition: landscape.h:272
void DegreesDump()
Prints the sum of day degrees. See FarmManager::daydegrees.
Definition: Landscape.cpp:1687
int m_minmaxextent
Definition: landscape.h:142
Population_Manager * m_ThePopManager
a pointer to the current main population manager
Definition: landscape.h:155
void CentroidSpiralOut(int a_polyref, int &a_x, int &a_y)
Definition: Landscape.cpp:3073
int hb_border_pixels
Definition: landscape.h:276
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:197
int SupplyLENext(void)
Definition: Landscape.cpp:3555
bool SupplyOverspray(int a_x, int a_y)
Gets the overspray flag.
Definition: Landscape.cpp:599
void SetBirdSeedForage(int a_polyref, double a_fooddensity)
Sets the grain forage resource as seen from a goose standpoint at a polygon.
Definition: landscape.h:528
void SetBirdMaizeForage(int a_polyref, double a_fooddensity)
Sets the maize forage resource as seen from a goose standpoint at a polygon.
Definition: landscape.h:535
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: landscape.h:1662
double SupplyTotalNectar(int a_x, int a_y)
Definition: landscape.h:384
void CreatePondList()
Creates a list of pond polygon refs/indexes for easy look up.
Definition: Landscape.cpp:2594
std::string EventtypeToString(int a_event)
Definition: Landscape.cpp:3918
int SupplyVegPhase(int a_poly)
Definition: landscape.h:179
RodenticidePredators_Population_Manager * SupplyRodenticidePredatoryManager()
Definition: landscape.h:432
int hb_width
Definition: landscape.h:269
void ResetGrainAndMaize()
Resets all grain.
Definition: Landscape.cpp:730
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
Definition: landscape.h:162
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
Definition: landscape.h:781
int hb_size
Definition: landscape.h:271
double SupplyPolygonAreaVector(int a_polyref)
Returns the area of a polygon using the vector index as a reference.
Definition: landscape.h:1200
std::string VegtypeToString(TTypesOfVegetation a_veg)
Definition: Landscape.cpp:4235
void hb_AddNewHedgebanks(int a_orig_poly_num)
Definition: hedgebanks.cpp:198
int * hb_map
Definition: landscape.h:268
double SupplyLAGreen(int a_polyref)
Definition: landscape.h:1041
int SupplyGrazingPressure(int a_polyref)
Definition: landscape.h:1227
int SupplyDayInMonth(void)
Definition: landscape.h:1606
void SetLESignal(int a_polyref, LE_Signal a_signal)
Definition: Landscape.cpp:3570
TTypesOfLandscapeElement SupplyElementTypeFromVector(unsigned int a_index)
Definition: landscape.h:1104
Population_Manager * SupplyThePopManager()
Get the pointer to the current main population manager.
Definition: landscape.h:175
int CorrectWidth(int x)
Definition: landscape.h:1567
int SupplyTreeAge(int, int)
Definition: landscape.h:509
bool m_toxShouldSpray
Definition: landscape.h:317
int SupplyFarmArea(int a_polyref)
Definition: landscape.h:1206
int SupplyRandomPondRef()
Returns random pond polyref.
Definition: Landscape.cpp:2610
void ReadOpenness(void)
Reads openness values from a standard input file for all polygons.
int SupplyTreeHeight(int)
Definition: landscape.h:816
int SupplySimAreaMinExtent(void)
int hb_StripingDist(void)
Definition: hedgebanks.cpp:225
bool BorderNeed(TTypesOfLandscapeElement a_letype)
Definition: Landscape.cpp:4529
int SupplyRandomPondIndex()
Returns random pond index.
Definition: Landscape.cpp:2606
void BeetleBankAdd(int x, int y, int angle, int length, LE *a_field, TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2971
TTypesOfPesticide m_PesticideType
An attribute to hold the pesticide type being tested, if there is one, if not default is -1.
Definition: landscape.h:278
~Landscape(void)
Definition: Landscape.cpp:1424
double SupplyGooseGrazingForageH(double a_height, GooseSpecies a_goose)
Returns the leaf forage resource as seen from a goose standpoint at a polygon based on the height onl...
Definition: landscape.h:541
bool SupplyMaleNewtPresent(int a_InPondIndex)
Determines if a male is present in a pond.
Definition: landscape.h:351
bool SupplyLEHigh(int a_x, int a_y)
Tests whether the polygon at a_x,a_y is designated as high.
Definition: landscape.h:455
PollenNectarQuality SupplyNectar(int a_polyref)
Definition: landscape.h:381
bool hb_HasNeighbourColor(int a_x, int a_y, int a_neighbour_color)
Definition: hedgebanks.cpp:452
FarmManager * SupplyFarmManagerPtr()
Definition: landscape.h:353
int SupplyWindDirection(void)
Definition: landscape.h:1423
vector< int > hb_hedges
Definition: landscape.h:263
GooseFieldList * GetGooseFields(double)
Gets the list of suitable goose foraging fields today.
Definition: Landscape.cpp:685
double SupplyMeanTemp(long a_date, unsigned int a_period)
Definition: landscape.h:1372
char m_versioninfo[30]
Definition: landscape.h:115
void DumpMapInfoByArea(const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
Definition: Landscape.cpp:3652
std::string PolytypeToString(TTypesOfLandscapeElement a_le_type)
Definition: Landscape.cpp:4087
void PolysRenumber(void)
Definition: Landscape.cpp:2057
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1099
int SupplyHour(void)
Get the hour of the day.
Definition: landscape.h:1586
double SupplyPolygonArea(int a_polyref)
Definition: landscape.h:523
TTypesOfVegetation SupplyLastSownVeg(int a_polyref)
Definition: landscape.h:1068
double SupplyRain(void)
Definition: landscape.h:1365
double SupplyPesticideS(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets soil pesticide for a location.
Definition: Landscape.cpp:616
int LineHighTest(int a_cx, int a_cy, double a_offsetx, double a_offsety)
Provides a measure of the shortest distance in using a vector from a_cx,a_cy unitl tall obstacles are...
Definition: Landscape.cpp:461
double SupplyDaylightProp()
Definition: landscape.h:825
int m_width10
Definition: landscape.h:140
bool BorderTest(int a_fieldpoly, int a_borderpoly, int a_x, int a_y)
Definition: Landscape.cpp:2452
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3688
bool BeetleBankPossible(LE *a_field, TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2772
int SupplyFarmOwnerIndex(int a_x, int a_y)
Definition: landscape.h:1165
bool SupplySkScrapes(int a_polyref)
Definition: landscape.h:981
int SupplyJustSprayed(int a_polyref)
Definition: landscape.h:1275
void CorrectCoords(int &x, int &y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1535
void SetMaleNewtPresent(int a_InPondIndex)
Sets a male as being present in a pond.
Definition: landscape.h:349
int SupplyYear(void)
Definition: landscape.h:1611
int SupplyCentroidX(int a_x, int a_y)
Definition: landscape.h:474
void DumpVegAreaData(int a_day)
Definition: Landscape.cpp:4680
void BorderRemoval(void)
Definition: Landscape.cpp:2271
int SupplyMinute(void)
Get the minute of the hour.
Definition: landscape.h:1592
int * SupplyMagicMapP(int a_x, int a_y)
Definition: landscape.h:1509
void EventDumpPesticides(int x1, int y1)
Definition: Landscape.cpp:1720
void GISASCII_Output(string outpfile, int UTMX, int UTMY)
Write ASCII file of the ALMaSS map.
Definition: Landscape.cpp:3507
void hb_FindHedges(void)
Definition: hedgebanks.cpp:276
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
void InitOsmiaBeeNesting()
Read in the Osmia nest density files and allocate to each LE object.
Definition: Landscape.cpp:4697
int SupplySoilType(int a_x, int a_y)
Returns the soil type in ALMaSS types reference numbers.
Definition: landscape.h:460
RodenticideManager * m_RodenticideManager
Definition: landscape.h:157
void AddBeetleBanks(TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2723
int FindLongestAxis(int *x, int *y, int *a_length)
Definition: Landscape.cpp:2851
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
void hb_DownPolyNumbers(void)
Definition: hedgebanks.cpp:715
APoint SupplyCentroidIndex(int a_polyrefindex)
Definition: Landscape.cpp:771
int m_y_add[8]
Definition: landscape.h:267
bool SubtractPondLarvalFood(double a_food, int a_polyrefindex)
Removes larval food from a pond and returns true if it was possible, otherwise false.
Definition: Landscape.cpp:664
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: landscape.h:1648
void CheckForPesticideRecord(LE *a_field, TTypesOfPesticideCategory a_pcide)
Check if needed and record pesticide application.
Definition: Landscape.cpp:669
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1493
int SupplyPesticideCell(int a_polyref)
Definition: landscape.h:1468
double SupplyTotalPollen(int a_polyref)
Definition: landscape.h:379
bool SupplyIsCereal2(TTypesOfVegetation a_vege_type)
Definition: Landscape.cpp:532
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: landscape.h:1655
void DumpTreatCounters(const char *a_filename)
Definition: Landscape.cpp:3586
int SupplyDayInYear(void)
Definition: landscape.h:1596
int SupplyFarmOwner(int a_x, int a_y)
Definition: landscape.h:1152
int SupplyOpenness(int a_x, int a_y)
Get openness for a location.
Definition: landscape.h:453
APoint CorrectCoordsPt(int x, int y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1544
void RebuildPolyMapping()
Definition: landscape.h:213
int SupplyVegAge(int a_Polyref)
Definition: landscape.h:1078
TTypesOfPesticide SupplyPesticideType(void)
Definition: landscape.h:433
void RodenticidePredatorsEvaluation(RodenticidePredators_Population_Manager *a_rppm)
Definition: Landscape.cpp:3032
int SupplyValidY(int a_polyref)
Definition: landscape.h:1481
void Tick(void)
Definition: Landscape.cpp:1467
bool SupplyJustMownVector(unsigned int a_index)
Definition: landscape.h:1258
void WriteOpenness(void)
Stores openness for all polygons to a standard file.
int GetQuarryNumbers(int a_poly)
This returns the number of geese which are legal quarry on the polygon the day before.
Definition: Landscape.cpp:3390
double * l_vegtype_areas
Definition: landscape.h:153
bool SupplyShouldSpray()
Definition: landscape.h:357
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:158
void hb_ClearPolygon(int a_poly_num)
Definition: hedgebanks.cpp:413
bool SupplyHasTramlines(int a_x, int a_y)
Definition: landscape.h:1252
double SupplyBirdSeedForage(int a_polyref)
Returns the grain forage resource.
Definition: landscape.h:614
double SupplyTrafficLoad(int a_x, int a_y)
Definition: landscape.h:1293
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:122
void hb_MarkTopFromLocalMax(int a_color)
Definition: hedgebanks.cpp:679
int SupplyCentroidX(int a_polyref)
Definition: landscape.h:470
void SetPolyMaxMinExtents(void)
Definition: Landscape.cpp:1622
double SupplyVegDigestability(int a_polyref)
Definition: landscape.h:919
void RemoveMissingValues()
A method for replacing missing values in the map with corrected ones - slow.
Definition: Landscape.cpp:2090
void hb_ResetColorBits(void)
Definition: hedgebanks.cpp:298
void SimulationClosingActions()
Definition: Landscape.cpp:1455
void ConsolidatePolys(void)
Definition: Landscape.cpp:1329
double SupplyRainPeriod(long a_date, int a_period)
Definition: landscape.h:1351
void AddGreenElement(LE *a_green)
int hb_height
Definition: landscape.h:270
double SupplyVegBiomassVector(unsigned int a_index)
Definition: landscape.h:948
PollenNectarQuality SupplyNectar(int a_x, int a_y)
Definition: landscape.h:382
int m_maxextent
Definition: landscape.h:143
int le_signal_index
Definition: landscape.h:319
void RecordGooseSpNumbers(int a_poly, int a_number, GooseSpecies a_goose)
This records the number of geese of each species on the polygon the day before. To prevent lots of un...
Definition: Landscape.cpp:3352
void ForceArea(void)
Definition: Landscape.cpp:2072
bool FindValidXY(int a_field, int &a_x, int &a_y)
Definition: Landscape.cpp:2688
double SupplySnowDepth(void)
Definition: landscape.h:1444
int m_treatment_counts[last_treatment]
Definition: landscape.h:193
void UpdateOsmiaNesting()
Tesll all LE objects to update their osmia nest status.
Definition: landscape.h:856
bool m_NeedCentroidCalculation
a flag to ensure centroid calculation on object construction
Definition: landscape.h:146
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
Curve relatning goose intake rates in KJ/min to vegetation height.
Definition: landscape.h:160
bool SupplyVegPatchy(int a_polyref)
Definition: landscape.h:986
void ReadPolys2(const char *a_polyfile)
reads in polygon information. Version 2 including centroid and openness information
Definition: Landscape.cpp:1892
void RecordGooseNumbersTimed(int a_poly, int a_number)
This records the number of geese on the polygon the day before at a predefined time....
Definition: Landscape.cpp:3341
void BorderAdd(LE *a_field, TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:2347
bool ReadSymbols(const char *a_cfgfile)
Definition: landscape.h:788
int SupplyUnderGrowthWidth(int)
Definition: landscape.h:817
int SupplyValidX(int a_polyref)
Definition: landscape.h:1474
double SupplyPesticideP(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets plant pesticide for a location.
Definition: Landscape.cpp:605
int MagicMapP2PolyRef(int a_magic)
Definition: landscape.h:1516
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
void hb_MarkTheBresenhamWay(void)
Definition: hedgebanks.cpp:629
RasterMap * m_land
The big map.
Definition: landscape.h:125
int SupplyLECount(void)
Definition: Landscape.cpp:3562
void AxisLoopLtd(int a_poly, APoint *a_cor, int a_axis, int a_limit)
Definition: Landscape.cpp:2917
int SupplyPolyRefVector(unsigned int a_index)
Definition: landscape.h:1451
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1331
const char * SupplyVersion(void)
Definition: landscape.h:778
bool hb_PaintWhoHasNeighbourColor(int a_neighbour_color, int a_new_color)
Definition: hedgebanks.cpp:526
double SupplyGreenBiomass(int a_polyref)
Definition: landscape.h:1017
double SupplyBirdSeedForage(int a_x, int a_y)
Returns the grain forage resource as seen from a goose standpoint at an x,y location.
Definition: landscape.h:621
TTypesOfVegetation SupplyVegTypeVector(unsigned int a_index)
Definition: landscape.h:1220
int SupplyElementSubType(int a_polyref)
Definition: landscape.h:1121
void DumpCentroids(void)
Definition: Landscape.cpp:3275
double GetActualGooseGrazingForage(int a_x, int a_y, GooseSpecies a_goose)
Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,...
Definition: landscape.h:596
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1321
double SupplyRodenticide(int a_x, int a_y)
Gets total rodenticide for a location.
Definition: Landscape.cpp:492
void CalculateCentroids(void)
Definition: Landscape.cpp:3040
int SupplyNumberOfFarms()
Definition: landscape.h:1148
int GetPolymapping(int a_index)
Definition: landscape.h:183
void hb_Cleanup(void)
double SupplyTempPeriod(long a_date, int a_period)
Definition: landscape.h:1410
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
int SupplySoilTypeR(int a_x, int a_y)
Returns the soil type in rabbit warren reference numbers.
Definition: landscape.h:464
int SupplyFarmAnimalCensus(int a_farm_ref, int a_LifeStage)
Definition: Landscape.cpp:745
int CalulateFieldOpennessCentroid(int a_pref)
Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles...
Definition: Landscape.cpp:359
double SupplyVegCoverVector(unsigned int a_index)
Definition: landscape.h:1053
int m_x_add[8]
Definition: landscape.h:266
bool hb_HasOtherNeighbour(int a_x, int a_y)
Definition: hedgebanks.cpp:339
bool SupplyIsGrass2(TTypesOfVegetation a_vege_type)
Definition: Landscape.cpp:503
void DumpAllSymbolsAndExit(const char *a_dumpfile)
Definition: landscape.h:785
bool SupplyIsGrass(int a_polyref)
Definition: landscape.h:1310
double SupplyTotalPollen(int a_x, int a_y)
Definition: landscape.h:380
int SupplyLargestPolyNumUsed()
Definition: landscape.h:355
void PolysValidate(bool a_exit_on_invalid)
Definition: Landscape.cpp:1746
int SupplyOpenness(int a_poly)
Get openness for a polygon.
Definition: landscape.h:451
bool SupplyPesticideDecay(PlantProtectionProducts a_ppp)
Returns true if there is any pesticide in the system at all at this point.
Definition: Landscape.cpp:776
void ReadPolys(const char *a_polyfile)
bool SupplySnowcover(void)
Definition: landscape.h:1437
int SupplyTreeAge(int a_Polyref)
Definition: landscape.h:1315
bool SupplyIsCereal(int a_polyref)
Definition: landscape.h:1300
double SupplyNightProp()
Definition: landscape.h:826
PollenNectarQuality SupplyPollen(int a_x, int a_y)
Definition: landscape.h:378
double SupplyPondPesticide(int a_poly_index)
Get the pesticide concentration per liter from a pond (must be a pond index on calling)
Definition: landscape.h:761
Farm * SupplyFarmPtr(int a_owner)
Definition: landscape.h:352
double SupplyLATotal(int a_x, int a_y)
Definition: landscape.h:1004
void RecordGooseRoostDist(int a_polyref, int a_dist, GooseSpecies a_goose)
Records the distance to the closest roost of goose species.
Definition: Landscape.cpp:3373
int hb_max_x
Definition: landscape.h:272
bool UMarginTest(int a_fieldpoly, int a_borderpoly, int a_x, int a_y, int a_width)
Definition: Landscape.cpp:2669
void PolysDump(const char *a_filename)
Definition: Landscape.cpp:1803
void SetPolymapping(int a_index, int a_val)
Definition: landscape.h:182
Landscape(void)
Definition: Landscape.cpp:814
void hb_Add(void)
Definition: hedgebanks.cpp:56
void DumpMap(const char *a_filename)
Definition: Landscape.cpp:1386
LE_Signal SupplyLESignal(int a_polyref)
Definition: Landscape.cpp:3566
bool PolysRemoveInvalid(void)
Definition: Landscape.cpp:1772
void hb_UpPolyNumbers(void)
Definition: hedgebanks.cpp:289
double SupplyBirdMaizeForage(int a_x, int a_y)
Returns the maize forage resource as seen from a goose standpoint at an x,y location.
Definition: landscape.h:640
void ReleaseOsmiaNest(int a_x, int a_y)
Reopen the osmia nest here
Definition: landscape.h:871
bool hb_FindBoundingBox(int a_poly_num)
Definition: hedgebanks.cpp:243
int hb_max_y
Definition: landscape.h:273
double SupplyBirdMaizeForage(int a_polyref)
Returns the maize forage resource.
Definition: landscape.h:628
int SupplyMonth(void)
Definition: landscape.h:1601
int SupplyCentroidY(int a_x, int a_y)
Definition: landscape.h:475
void UnsprayedMarginAdd(LE *a_field)
Definition: Landscape.cpp:2617
unsigned int SupplyNumberOfPolygons(void)
Definition: landscape.h:1461
int CorrectHeight(int y)
Definition: landscape.h:1573
int SupplyRoadWidth(int, int)
Definition: landscape.h:811
double SupplyVegBiomass(int a_polyref)
Definition: landscape.h:953
bool StepOneValid(int a_polyindex, int a_x, int a_y, int step)
Definition: Landscape.cpp:2429
int hb_first_free_poly_num
Definition: landscape.h:274
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
A farm that carries out crop, pesticide and fertilizer planning using simplified optimisation or othe...
Definition: farm.h:2029
Definition: pesticide.h:107
Definition: pesticide.h:370
Definition: plants.h:215
A polynomial curve class.
Definition: CurveClasses.h:90
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1183
Base class for all population managers.
Definition: PopulationManager.h:424
Definition: rastermap.h:41
int Get(int a_x, int a_y)
Definition: rastermap.h:81
int * GetMagicP(int a_x, int a_y)
Definition: rastermap.h:74
Class for management of bait locations.
Definition: Rodenticide.h:73
Definition: RodenticidePredators.h:51
Definition: skylarks_all.h:343
double GetWindPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:262
bool GetSnow(long a_date)
Definition: weather.cpp:132
double GetWind(long a_date)
Definition: weather.h:425
double GetMeanTemp(long a_date, unsigned int a_period)
Definition: weather.cpp:120
double GetRain(long a_date)
Definition: weather.h:423
int GetWindDirection(void)
Definition: weather.h:427
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:253
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
double GetTempPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:272
double GetGlobalRadiation(long a_date)
Definition: weather.h:414
double GetHumidity(void)
Get the humidity score today.
Definition: weather.h:421
double GetSnowDepth(void)
Get the current snow depth.
Definition: weather.h:431
class Configurator * g_cfg
Definition: configurator.cpp:49
CfgSecureLevel
Definition: configurator.h:59
class LE_TypeClass * g_letype
Definition: elements.cpp:277
unsigned int LE_Signal
Definition: elements.h:35
PlantProtectionProducts
A list PPP names for tracking by the Pesticide class.
Definition: farm.h:421
TTypesOfOptFarms
Definition: farm.h:278
TTypesOfFarm
Definition: farm.h:222
vector< unsigned > polylist
Definition: farm.h:207
const int January
Definition: landscape.h:36
TTypeOfDirections
ALMaSS 8 standard directions
Definition: landscape.h:59
@ direction_se
Definition: landscape.h:60
@ direction_nw
Definition: landscape.h:60
@ direction_w
Definition: landscape.h:60
@ direction_s
Definition: landscape.h:60
@ direction_ne
Definition: landscape.h:60
@ direction_n
Definition: landscape.h:60
@ direction_e
Definition: landscape.h:60
@ direction_sw
Definition: landscape.h:60
const int June
Definition: landscape.h:41
const int November
Definition: landscape.h:46
const int October
Definition: landscape.h:45
const int July
Definition: landscape.h:42
const int March
Definition: landscape.h:38
const int May
Definition: landscape.h:40
const int September
Definition: landscape.h:44
std::vector< GooseFieldListItem > GooseFieldList
A list of GooseFieldListItem s.
Definition: landscape.h:103
const int August
Definition: landscape.h:43
const int April
Definition: landscape.h:39
const int February
Definition: landscape.h:37
class Pesticide * g_pest
Definition: pesticide.cpp:92
const int December
Definition: landscape.h:47
TTypesOfPesticideCategory
Definition: landscape.h:63
@ insecticide
Definition: landscape.h:63
@ fungicide
Definition: landscape.h:63
@ testpesticide
Definition: landscape.h:63
@ herbicide
Definition: landscape.h:63
TTypesOfPesticide
Definition: landscape.h:66
@ ttop_ModelinkPesticide
Definition: landscape.h:71
@ ttop_ModelinkPesticide21TWA
Definition: landscape.h:72
@ ttop_NoPesticide
Definition: landscape.h:67
@ ttop_AcuteEffects
Definition: landscape.h:68
@ ttop_eggshellthinning
Definition: landscape.h:75
@ ttop_GeneticDemo
Definition: landscape.h:73
@ ttop_Vinclozolin
Definition: landscape.h:70
@ ttop_MultipleEffects
Definition: landscape.h:74
@ ttop_AcuteDelayedEffects
Definition: landscape.h:76
@ ttop_ReproductiveEffects
Definition: landscape.h:69
Landscape * g_map
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
@ WARN_MSG
Definition: maperrormsg.h:38
A list item entry of field polygon reference numbers with associated openness and goose food scores.
Definition: landscape.h:81
double grass[gs_foobar]
Definition: landscape.h:91
TTypesOfVegetation vegtype
Definition: landscape.h:92
int geese
Definition: landscape.h:83
double grain
Definition: landscape.h:89
std::string vegtypechr
Definition: landscape.h:93
std::string lastsownveg
Definition: landscape.h:98
int polyref
Definition: landscape.h:82
std::string debugveg
Definition: landscape.h:99
double digestability
Definition: landscape.h:95
double openness
Definition: landscape.h:88
double maize
Definition: landscape.h:90
int geesespTimed[gs_foobar]
Definition: landscape.h:86
std::string previouscrop
Definition: landscape.h:97
int geeseTimed
Definition: landscape.h:85
int roostdists[gs_foobar]
Definition: landscape.h:87
double vegheight
Definition: landscape.h:94
int vegphase
Definition: landscape.h:96
int geesesp[gs_foobar]
Definition: landscape.h:84
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
@ tole_PermPastureTussocky
Definition: tole_declaration.h:45
@ tole_WoodyEnergyCrop
Definition: tole_declaration.h:94
@ tole_PermPastureTussockyWet
Definition: tole_declaration.h:100
@ tole_PermanentSetaside
Definition: tole_declaration.h:46
@ tole_Field
Definition: tole_declaration.h:43
@ tole_PermPasture
Definition: tole_declaration.h:47
@ tole_Vildtager
Definition: tole_declaration.h:99
@ tole_Orchard
Definition: tole_declaration.h:71
@ tole_YoungForest
Definition: tole_declaration.h:55
@ tole_PermPastureLowYield
Definition: tole_declaration.h:44
TTypesOfVegetation
Definition: tov_declaration.h:30
@ last_treatment
Definition: treatment.h:113
class Weather * g_weather
Definition: weather.cpp:41